﻿using Adalbertus.BudgetPlanner.Domain;
using FluentNHibernate.Mapping;

namespace Adalbertus.BudgetPlanner.Infrastructure.Mapping
{
    public class BudgetMap : ClassMap<Budget>
    {
        public BudgetMap()
        {
            Id(x => x.Id);

            Map(x => x.DateFrom);
            Map(x => x.DateTo);
            Map(x => x.IsDraft);

            HasMany(x => x.Incomes);
            HasMany(x => x.Savings);
            HasMany(x => x.BudgetPlanItems).Cascade.AllDeleteOrphan();
            HasMany(x => x.Expenses).Cascade.AllDeleteOrphan();
        }
    }
}
